<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Login extends CI_Controller {
    function index()
    {
        $data=array();
        if($this->input->post('login')!=null)
        {
            $this->load->model('common');
            $data=array('username'=>$this->input->post('user'),'password'=>$this->input->post('pass'));
            $rs=$this->common->GetById('users',$data);
            //print_r($data);
            if($rs)
            {
                $data['user_info']=$rs[0];
                $this->session->set_userdata('user_info',$rs[0]);
                redirect(base_url());
            }
            $data['error']="Can't login";
           
        }
        $this->load->view('login',$data);
    }
}